﻿// StructAssignment.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>
using namespace std;
#include "types.h"

typedef struct
{
	UI32	uiFile : 12;
	UI32	uiFont : 8;
	UI32	uiAtb : 12;
} LoadSaveTile;

typedef struct
{
	UI32	uiRoadFile : 12;
	UI32	uiRoadFont : 8;
	UI32	uiRoadAtb : 12;
} LoadSaveRoad;

struct	LoadSaveMapTI
{
	LoadSaveTile		stLoadSaveTile;
	LoadSaveRoad		stLoadSaveRoad;

	UI16				uiObjectInfo;
};

struct	ObjectInfoBaseBf
{
	UI16	uiCode : 3;
	UI16	siParameter : 13;
};

struct	ObjectInfoRelativePosBf
{
	UI16	uiCode : 3;
	SI16	siReverse : 1;
	SI16	siX : 6;
	SI16	siY : 6;
};

union	ObjectInfoBfs
{
	ObjectInfoBaseBf			BaseBf;
	ObjectInfoRelativePosBf		RelativePosBf;
};

int main()
{
	UI16 uiObjectInfo = 33022;
	ObjectInfoBfs* pObjectInfoBfs = (ObjectInfoBfs*)&uiObjectInfo;
	char tmp[1024];
	sprintf_s(tmp, "objinfo=%d uiCode=%d siParameter=%d ruiCode=%d rsiReverse=%d rX=%d rY=%d \n",
		uiObjectInfo,
		pObjectInfoBfs->BaseBf.uiCode,
		pObjectInfoBfs->BaseBf.siParameter,
		pObjectInfoBfs->RelativePosBf.uiCode,
		pObjectInfoBfs->RelativePosBf.siReverse,
		pObjectInfoBfs->RelativePosBf.siX,
		pObjectInfoBfs->RelativePosBf.siY
	);
	cout << tmp << endl;
}
